*****************************************************
*Table A2: Descriptive statistics: Industrial robots*
*****************************************************

use "$clean_data_automation/apr_measures_ifr19.dta", clear

keep industry_ifr19 apr_us_lv93_ apr_us_lv07_ apr_us_lv93_07_ apr_euro7_lv93_ apr_euro7_lv93_07_ emp_us_

gen industry_name = "Agriculture" if industry_ifr19=="agriculture"
replace industry_name = "Automotive" if industry_ifr19=="automotive"
replace industry_name = "Construction" if industry_ifr19=="construction"
replace industry_name = "Electronics" if industry_ifr19=="electronics"
replace industry_name = "Food and Beverages" if industry_ifr19=="food"
replace industry_name = "Wood and Furniture" if industry_ifr19=="furniture"
replace industry_name = "Miscellaneous" if industry_ifr19=="manufacturing_other"
replace industry_name = "Basic Metals" if industry_ifr19=="metal_basic"
replace industry_name = "Industrial Machinery" if industry_ifr19=="metal_machinery"
replace industry_name = "Metal Products" if industry_ifr19=="metal_products"
replace industry_name = "Minerals" if industry_ifr19=="mineral"
replace industry_name = "Mining" if industry_ifr19=="mining"
replace industry_name = "Paper and Printing" if industry_ifr19=="paper"
replace industry_name = "Plastics and Chemicals" if industry_ifr19=="petrochemicals"
replace industry_name = "Education and Research" if industry_ifr19=="research"
replace industry_name = "Services" if industry_ifr19=="services"
replace industry_name = "Textiles" if industry_ifr19=="textiles"
replace industry_name = "Utilities" if industry_ifr19=="utilities"
replace industry_name = "Shipbuilding and Aerospace" if industry_ifr19=="vehicles_other"

gen id = .
replace id = 1 if industry_name=="Agriculture"
replace id = 2 if industry_name=="Automotive"
replace id = 3 if industry_name=="Basic Metals"
replace id = 4 if industry_name=="Construction"
replace id = 5 if industry_name=="Education and Research"
replace id = 6 if industry_name=="Electronics"
replace id = 7 if industry_name=="Food and Beverages"
replace id = 8 if industry_name=="Industrial Machinery"
replace id = 9 if industry_name=="Metal Products"
replace id = 10 if industry_name=="Minerals"
replace id = 11 if industry_name=="Mining"
replace id = 12 if industry_name=="Miscellaneous"
replace id = 13 if industry_name=="Paper and Printing"
replace id = 14 if industry_name=="Plastics and Chemicals"
replace id = 15 if industry_name=="Services"
replace id = 16 if industry_name=="Shipbuilding and Aerospace"
replace id = 17 if industry_name=="Textiles"
replace id = 18 if industry_name=="Utilities"
replace id = 19 if industry_name=="Wood and Furniture"

sort industry_name

foreach var of varlist apr_* {
	replace `var' = round(`var', 0.01)
}

replace emp_us_ = round(emp_us_, 1)

*Generate variable with absolute (relative)
tostring apr_*, replace format(%17.4g) force
tostring emp_us_, replace force

foreach var of varlist apr_* {
replace `var' = `var' + ".00" if `var'=="0"
replace `var' = `var' + "0" if length(`var')==2&substr(`var',1,1)=="."
replace `var' = substr(`var',1,3) if substr(`var',1,1)=="."
replace `var' = "-0" + substr(`var',2,3) if substr(`var',1,2)=="-."
replace `var' = "0" + `var' if length(`var')==3 & substr(`var',1,1)=="."
replace `var' = `var' + ".0" if length(`var')==2
replace `var' = `var' + "0" if length(`var')==3
}

keep industry_name apr_us_lv93_ apr_us_lv93_07_ apr_euro7_lv93_ apr_euro7_lv93_07_ emp_us_
order industry_name apr_us_lv93_ apr_us_lv93_07_ apr_euro7_lv93_ apr_euro7_lv93_07_ emp_us_
br
